# -*- coding: utf-8 -*-
# @Time    : 2024/11/7 下午1:56
# @Author  : xiaowanzi
# @File    : log_start_end_warps.py
from functools import wraps
from base.log import logger


def log_start_end(*pargs):
    def _wrapper(func):
        @wraps(func)
        def __wrapper(*args, **kwargs):
            if 'run_id' in dir(args[0]):
                logger.info(
                    "【%s 开始-%s】--[%s,%s]" % (str(pargs[0]), func._name__, args[0].case_id, args[0].run_id))
            else:
                logger.info("【%s 开始-%s】" % (str(pargs[0]), func.__name__))
            result = func(*args, **kwargs)
            if 'run_id' in dir(args[0]):
                logger.info("【%s 结束-%s】--[%s,%s]" % (str(pargs[0]), func.__name__, args[0].case_id, args[0].run_id))
            else:
                logger.info("【%s 结束-%s】" % (str(pargs[0]), func.__name__))
            return result

        return __wrapper

    return _wrapper
